﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BLL;
namespace Business
{
    /// <summary>
    /// 加载管理
    /// </summary>
    public class LoadMange
    {
        /// <summary>
        /// 加载用户基本数据
        /// </summary>
        /// <param name="EMail"></param>
        /// <returns></returns>
        public static _userinfo Load_userifno(string EMail)
        {
            BLL_userinfo bll_ui = new BLL_userinfo();
            _userinfo ui = new _userinfo();
            ui._user_email = EMail;
            return bll_ui.search(ui, "_user_email");
        }

        /// <summary>
        /// 加载过时的任务
        /// </summary>
        /// <param name="EMail"></param>
        /// <returns></returns>
        public static List<task> Load_past_task(string EMail)
        {
            BLL_task bll_tk = new BLL_task();
            task tk = new task();
            tk.task_refrences_user_email = EMail;
            tk.task_state = DefaultDB.DF_TASKSTATE_PAST;
            List<task> result = new List<task>();
            result = bll_tk.search(tk, "task_state");
            return result;
        }

        /// <summary>
        /// 加载进行中的任务
        /// </summary>
        /// <param name="EMail"></param>
        /// <returns></returns>
        public static List<task> Load_ing_task(string EMail)
        {
            BLL_task bll_tk = new BLL_task();
            task tk = new task();
            tk.task_refrences_user_email = EMail;
            tk.task_state = DefaultDB.DF_TASKSTATE_ING;
            List<task> result = new List<task>();
            result = bll_tk.search(tk, "task_state");

            //if (result != null)
            //{
            //    for (int i = 0; i < result.Count; i++)
            //    {
            //        //DateTime dt = result[i].task_time;

            //        string str_date = result[i].task_time.ToString();

            //        if (str_date != "")
            //        {
            //            string[] str_space = str_date.Split(' ');
            //            string[] str = str_space[0].Split('/');
            //            //string[] str = str_task_time.Split('/');
            //            //DateTime dt = new DateTime(Convert.ToInt32(str[0]), Convert.ToInt32(str[1]), Convert.ToInt32(str[2]));
            //            DateTime dt = new DateTime(2001,2,2);
            //            DateTime dt1 = Convert.ToDateTime("2007-8-1");
            //            result[i].task_time = dt;
            //        }
            //        //result[i].task_time = 
            //    }
            //}

            return result;
        }

        /// <summary>
        /// 加载完成的任务
        /// </summary>
        /// <param name="EMail"></param>
        /// <returns></returns>
        public static List<task> Load_finish_task(string EMail)
        {
            BLL_task bll_tk = new BLL_task();
            task tk = new task();
            tk.task_refrences_user_email = EMail;
            tk.task_state = DefaultDB.DF_TASKSTATE_FINISH;
            List<task> result = new List<task>();
            result = bll_tk.search(tk, "task_state");
        
            return result;
        }

        /// <summary>
        /// 加载联系人
        /// </summary>
        /// <param name="EMail"></param>
        /// <returns></returns>
        public static List<contact> Load_contact(string EMail)
        {
            BLL_contact bll_ct = new BLL_contact();
            contact ct = new contact();
            ct.contact_refrences_user_email = EMail;
            List<contact> result =new List<contact>();
            result = bll_ct.search(ct, "contact_refrences_user_email");
            return result;
        }

        /// <summary>
        /// 加载产品
        /// </summary>
        /// <param name="EMail"></param>
        /// <returns></returns>
        public static List<product> Load_product(string EMail)
        {
            BLL_product bll_pt = new BLL_product();
            product pt = new product();
            pt.product_refrences_user_email = EMail;
            List<product> result = new List<product>();
            result = bll_pt.search(pt, "product_refrences_user_email");
            return result;
        }

        /// <summary>
        /// 加载交易
        /// </summary>
        /// <param name="EMail"></param>
        /// <returns></returns>
        public static List<trade> Load_trade(string EMail)
        {
            BLL_trade bll_td = new BLL_trade();
            trade td = new trade();
            td.trade_refrences_user_email = EMail;
            List<trade> result = new List<trade>();
            result = bll_td.search(td, "trade_refrences_user_email");
            return result;
        }
    }
}
